{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "f30cfcc78a644e5bb3c81ff3e37d4ca6",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Plot(antialias=3, axes=['x', 'y', 'z'], background_color=16777215, camera=[4.5, 4.5, 4.5, 0.0, 0.0, 0.0, 1.0, …"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\"Use VTK commands to create a vtkImageData object and visualize it\"\"\"\n",
    "\n",
    "import vtk\n",
    "import numpy as np\n",
    "from vtkplotter import show\n",
    "\n",
    "n1, n2, n3 = 5,10,15\n",
    "raw = np.random.rand(n1*n2*n3).reshape(n1,n2,n3)\n",
    "\n",
    "img = vtk.vtkImageData()\n",
    "img.SetDimensions(raw.shape)\n",
    "\n",
    "raw = raw.transpose(2,1,0).flatten()\n",
    "arr = vtk.util.numpy_support.numpy_to_vtk(raw, array_type=vtk.VTK_FLOAT)\n",
    "img.GetPointData().SetScalars(arr)\n",
    "\n",
    "show(img)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
